#include "tk_rand.h"

#include <QtGlobal>
#include <QTime>

namespace tk{

void TkSRand()
{
    QTime current_time = QTime::currentTime();
    qsrand(tk_uint32(current_time.msecsSinceStartOfDay()));
}

tk_int32 TkRand()
{
    return qrand();
}

tk_int32 TkRand(tk_int32 min, tk_int32 max)
{
    tk_float diff = tk_float(max - min);
    tk_float factor = tk_float(qrand())/tk_float(RAND_MAX);

    return min + tk_int32(factor*diff);
}


}//namespace tk
